//
//  WYRInfo.m
//  异步下载网络图片
//
//  Created by 伍银荣 on 2021/8/31.
//  Copyright © 2021 com.WYR. All rights reserved.
//

#import "WYRAppInfo.h"

@implementation WYRAppInfo

+(instancetype)infoWithDictionary:(NSDictionary *)dict {
    WYRAppInfo *appInfo = [[WYRAppInfo alloc]init];
    //kvc设置属性值
    [appInfo setValuesForKeysWithDictionary:dict];
    return appInfo;
}

+ (NSArray *)appInfos {
    NSArray *arr = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"data.plist" ofType:nil]];
    //使用arrayWithCapacity:方法比单纯的array方法更能够提高运行效率
    NSMutableArray *mArr = [NSMutableArray arrayWithCapacity:10];
    for (NSDictionary *dict in arr) {
        WYRAppInfo *infoModel = [self infoWithDictionary:dict];
        [mArr addObject:infoModel];
    }
    //调用copy方法后返回一个不可变数组
    return [mArr copy];
}

@end
